/*
 *    Copyright 2009-2023 the original author or authors.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       https://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.apache.ibatis.ryan.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

/**
 * 分页数据封装
 */
public class PagedList<E> implements List<E>, PagedAble<E>, Serializable {
  private static final long serialVersionUID = -6726246716422199766L;
  private Integer pageNo;
  private Integer pageSize;
  private Integer totalPage;
  private Integer totalRow;

  private List<E> data = new ArrayList<>();

  public Integer getPageNo() {
    return this.pageNo;
  }

  public void setPageNo(Integer pageNo) {
    this.pageNo = pageNo;
  }

  public Integer getPageSize() {
    return this.pageSize;
  }

  public void setPageSize(Integer pageSize) {
    this.pageSize = pageSize;
  }

  public Integer getTotalPage() {
    return this.totalPage;
  }

  public void setTotalPage(Integer totalPage) {
    this.totalPage = totalPage;
  }

  public Integer getTotalRow() {
    return this.totalRow;
  }

  public void setTotalRow(Integer totalRow) {
    this.totalRow = totalRow;
  }

  public List<E> getData() {
    return this.data;
  }

  public Iterator<E> iterator() {
    return this.data.iterator();
  }

  public Spliterator<E> spliterator() {
    return this.data.spliterator();
  }

  public boolean add(E e) {
    return this.data.add(e);
  }

  public boolean addAll(Collection<? extends E> c) {
    return this.data.addAll(c);
  }

  public Stream<E> stream() {
    return StreamSupport.stream(this.spliterator(), false);
  }

  public E get(int index) {
    return this.data.get(index);
  }

  public int size() {
    return this.data.size();
  }

  public boolean isEmpty() {
    return this.data.isEmpty();
  }

  public boolean contains(Object o) {
    return this.data.contains(o);
  }

  public Object[] toArray() {
    return this.data.toArray();
  }

  public <T> T[] toArray(T[] a) {
    return this.data.toArray(a);
  }

  public boolean remove(Object o) {
    return this.data.remove(o);
  }

  public boolean containsAll(Collection<?> c) {
    return this.data.containsAll(c);
  }

  public boolean removeAll(Collection<?> c) {
    return false;
  }

  public boolean retainAll(Collection<?> c) {
    return this.data.retainAll(c);
  }

  public void clear() {
    this.data.clear();
  }

  public void forEach(Consumer<? super E> action) {
    this.data.forEach(action);
  }

  public boolean addAll(int index, Collection<? extends E> c) {
    return this.data.addAll(index, c);
  }

  public E set(int index, E element) {
    return this.data.set(index, element);
  }

  public void add(int index, E element) {
    this.data.add(index, element);
  }

  public E remove(int index) {
    return this.data.remove(index);
  }

  public int indexOf(Object o) {
    return this.data.indexOf(o);
  }

  public int lastIndexOf(Object o) {
    return this.data.lastIndexOf(o);
  }

  public ListIterator<E> listIterator() {
    return this.data.listIterator();
  }

  public ListIterator<E> listIterator(int index) {
    return this.data.listIterator(index);
  }

  public List<E> subList(int fromIndex, int toIndex) {
    return this.data.subList(fromIndex, toIndex);
  }
}
